<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>个人页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/userProfiles.css">
    <link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
    <link rel="stylesheet" href="/js/plugins/assets/css/amazeui.css">
    <link rel="stylesheet" href="/js/plugins/assets/css/app.css">
    <script src="/js/plugins/assets/js/amazeui.js"></script>
    <script src="/js/plugins/assets/js/app.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            //目标用户id
            var targetId = getParams().id;

            //当前登录用户id,源用户
            //查询用户信息
            $.get("/personMessage/" + targetId, function (data) {

                console.log(data);
                $(".info").renderValues(data);
            });


            var user = JSON.parse(sessionStorage.getItem('user'));
            var sourceId = user.id;


            //发送私信点击事件
            $('#letterBtn').on('click', function () {

                var targetUserName = $(".name").html();
                $("#targetUserName").html(targetUserName);

                //判断是否登录
                if (sourceId > 0) {
                    $('#my-prompt').modal({
                        relatedTarget: this,
                        onConfirm: function (e) {
                            var content = e.data;
                            $.ajax({
                                type: "post",
                                url: "/personMessage",
                                data: {sourceId: sourceId, targetId: targetId, content: content},
                                success: function (msg) {
                                    $(document).on('click', '#btn-21', function () {
                                        $(document).dialog({
                                            type: 'notice',
                                            infoText: '发送成功',
                                            autoClose: 1500,
                                            position: 'bottom'  // center: 居中; bottom: 底部
                                        });
                                    });
                                }
                            });
                        }
                    });
                } else {
                    //如果没有登录,需要登录
                    $(document).dialog({
                        type: 'confirm',
                        closeBtnShow: true,
                        content: '需要登录之后才能给该用户发送私信哦',
                        onClickConfirmBtn: function () {
                            window.parent.location.href = "/login.html"
                        },
                        onClickCancelBtn: function () {

                        }
                    });
                }
            });
            //进行游记的回显操作
            $.get("/sendMe/" + targetId, function (data) {
                console.log(data);
                $(".list").renderValues({list:data}, {
                    setHref: function (item, value) {
                        var href = $(item).data("href");
                        $(item).attr("href", href + value);
                    }
                })
            })
        });
    </script>
</head>
<body>
<div class="container bg" style="background-image: url(&quot;/img/user/bg.jpeg&quot;);">
    <a href="/travelPage.html" class="my-arrow">
        <span><i class="fa fa-chevron-left fa-2x"></i></span>
    </a>
    <div class="container">
        <div class="info">
            <img class="rounded-circle" width="17%" render-src="headImgUrl">
            <p class="name" render-html="nickName"></p>
            <p render-html="sign"></p>

            <div class="row num">
                <div class="col-2 border border-left-0 border-top-0 border-bottom-0">
                    <div>
                        <span>1</span>
                    </div>
                    <div>
                        <span>关注</span>
                    </div>
                </div>
                <div class="col-2">
                    <div>
                        <span>0</span>
                    </div>
                    <div>
                        <span>粉丝</span>
                    </div>
                </div>
                <div class="col">
                    <button class="btn btn-outline-success ibtn" id="letterBtn">私信</button>
                    <button class="btn btn-success ibtn" id="followBtn">关注</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="tabs">
    <ul class="nav nav-pills nav-justified  border border-left-0 border-top-0 border-right-0" id="pills-tab"
        role="tablist">
        <li class="nav-item">
            <a class="nav-link active" id="travels-tab" data-toggle="pill" href="#travels">
                TA的游记[<span>1</span>]
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link " id="comments-tab" data-toggle="pill" href="#comments">
                TA的点评[<span>1</span>]
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact">
                TA的旅行单[<span>0</span>]
            </a>
        </li>
    </ul>
    <div class="container tab-content" id="pills-tabContent">
        <div class="tab-pane fade show active" id="travels">

            <dl class="list">
                <dd render-loop="list">
                    <a data-href="/travelContent.html?id=" render-fun="setHref" render-key="list.id">
                        <img render-src="list.coverUrl">
                        <p><span class="title" render-html="list.title"></span>
                            <span class="span-right">
						 				<span>0</span> <i class="fa fa-thumbs-o-up"></i></span>
                        </p>
                    </a>
                    <hr>
                </dd>
            </dl>
        </div>

        <div class="comment tab-pane fade " id="comments">
            <input type="hidden" name="currentPage" value="1">
            <input type="hidden" name="pageSize" value="5">
            <input type="hidden" name="rows" value="1">
            <div>
                <div class="row">
                    <div class="col-2 comment-head">
                        <img class="rounded-circle" src="/upload/7e854d1d-a7be-4360-8943-8771d18ee0e3.jpg">
                    </div>
                    <div class="col">
                        <span class="comment-star"><i class="fa fa-star"></i><i class="fa fa-star"></i><i
                                class="fa fa-star"></i><i class="fa fa-star-o"></i><i class="fa fa-star-o"></i></span>

                        <span class="comment-date">2018-07-11</span>
                        <div class="comment-content">
                            <a href="strategyComment.html" data-id="4">
                                <p>骑了个单车到沙面，春风把从上下九和宝华路带来的燥热吹散。沙面临江，下午的时光让这富有异国风情的公园显得更加宁静惬意，哪怕...</p>
                            </a>
                        </div>
                        <ul class="comment-img">
                            <li>
                                <img src="/upload/63bb765d-5dff-44f8-b7f1-cb338b9b9f95.jpeg">
                            </li>
                            <li>
                                <img src="/upload/7d437f8d-a476-465c-bd84-e93a03d8efd5.jpeg">
                            </li>
                        </ul>

                        <div class="comment-link">
                            <a href="strategyCatalogs.html" data-id="2">
                                <img src="/upload/e5e8a1a7-b127-4145-9fd0-a94e29f752ba.jpeg"> <span>广州攻略</span>
                                <i class="fa fa-angle-right fa-2x"></i>
                            </a>
                        </div>

                    </div>
                </div>
            </div>

        </div>
        <div class="tab-pane fade" id="pills-contact">.3333..</div>
    </div>
</div>

<div class="am-modal am-modal-prompt" tabindex="-1" id="my-prompt">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">私信</div>
        <div class="am-modal-bd">
            @<span id="targetUserName"></span>
            <textarea type="text" class="am-modal-prompt-input" rows="5" style="width: 100%"></textarea>
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>发送</span>
        </div>
    </div>
</div>

</body>
</html>